// wtkrootwidget.hpp
//

#ifndef _WTKROOTWIDGET_HPP
#define _WTKROOTWIDGET_HPP

#include "wtk/wtkwidget.hpp"
#include "wtk/wtklayout.hpp"

namespace wtk
{
  class Display;



  // RootLayout
  //
  class WTK_API RootLayout : public Layout
  {
    struct WTK_API ChildLayout
    {
      Widget &child;
      SizeRequest request;
      bool fullscreen{false};
    };
    
  public:
    void set_root_size ( int width,
                         int height );
    void process_resize ();

    void set_child_properties ( Widget &child,
                                bool fullscreen );
    
    virtual void add_child ( Widget &child );
    virtual void remove_child ( Widget &child );
    virtual void clear ();
    
    virtual void size_request ( SizeRequest &req );
    virtual void size_allocate ( const Allocation &alloc );

  private:
    int width{};
    int height{};
    std::unordered_map<Widget *, ChildLayout> children_layout;
  };


  
  // RootWidget
  //
  class WTK_API RootWidget : public Widget
  {
    friend Display;

  public:
    virtual Display *get_display () { return &display; }
    virtual void draw ( const DrawContext &context );

  private:
    Display &display;
    
    RootWidget ( Display &display );

    void process_redraw ();
  };
}

#endif
